home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 22 / CU Amiga Magazine's Super CD-ROM 22 (1998)(EMAP Images)(GB)[!][issue 1998-05].iso / PowerPC / Programming / PPCsiod / SIOD / siod.scm < prev    next >
Text File  |  1993-10-01  |  7KB  |  190 lines

  1. ; Scheme In One Define.
  2. ; The garbage collector, the name and other parts of this program are
  3. ;
  4. ; *                     COPYRIGHT (c) 1989 BY                              *
  5. ; *      PARADIGM ASSOCIATES INCORPORATED, CAMBRIDGE, MASSACHUSETTS.       *
  6. ;
  7. ; Conversion  to  full scheme standard, characters, vectors, ports, complex &
  8. ; rational numbers, debug utils, and other major enhancments by
  9. ;
  10. ; *      Scaglione Ermanno, v. Pirinoli 16 IMPERIA P.M. 18100 ITALY        * 
  11. ;
  12. ; Permission  to use, copy, modify, distribute and sell this software and its
  13. ; documentation  for  any purpose and without fee is hereby granted, provided
  14. ; that  the  above  copyright  notice appear in all copies and that both that
  15. ; copyright   notice   and   this  permission  notice  appear  in  supporting
  16. ; documentation,  and that the name of Paradigm Associates Inc not be used in
  17. ; advertising or publicity pertaining to distribution of the software without
  18. ; specific, written prior permission.
  19. ;
  20. ; Runtime library for version 2.6
  21.  
  22. (define my-path "SIOD:")
  23.  
  24. (autoload-from-file (string-append my-path "cxr.scm")
  25.                     '(caar cadr cdar cddr 
  26.                       caaar caadr cadar caddr  
  27.                       cdaar cdadr cddar cdddr  
  28.                       caaaar caaadr caadar caaddr 
  29.                       cadaar cadadr caddar cadddr 
  30.                       cdaaar cdaadr cdadar cdaddr 
  31.                       cddaar cddadr cdddar cddddr
  32.                       1st 2nd 3rd 4th)
  33.                      user-global-environment)
  34.  
  35. (autoload-from-file (string-append my-path "delay.scm") 
  36.                     '(freeze thaw delay force delayed-object?)
  37.                     user-global-environment)
  38.  
  39. (autoload-from-file (string-append my-path "streams.scm")
  40.                     '(cons-stream head tail the-empty-stream 
  41.                       empty-stream? stream? stream->list list->stream
  42.                       stream-map stream-append stream-filter stream-ref
  43.                       stream-nth stream-for-each)
  44.                     user-global-environment)     
  45.  
  46. (autoload-from-file (string-append my-path "port.scm") 
  47.                     '(file-length open-binary-input-file
  48.                       open-binary-output-file open-input-file
  49.                       open-output-file open-extend-file
  50.                       current-input-port current-output-port
  51.                       newline page call-with-input-file
  52.                       call-with-output-file with-input-from-file
  53.                       with-output-to-file)
  54.                     user-global-environment)
  55.  
  56. (autoload-from-file (string-append my-path "string.scm")
  57.                     '(string<? string>? string=? string<=?
  58.                       string>=? string-CI<? string-CI=? string-null?)
  59.                     user-global-environment)
  60.  
  61.  
  62. (autoload-from-file (string-append my-path "substring.scm") 
  63.                     '(substring-CI<? substring-CI=? substring<?
  64.                       substring=? substring-fill! 
  65.                       substring-move-left! substring-move-right!
  66.                       substring-find-next-char-in-set 
  67.                       substring-find-previous-char-in-set)
  68.                     user-global-environment)
  69.  
  70. (autoload-from-file (string-append my-path "exp-imp.scm")
  71.                     '(implode explode)
  72.                     user-global-environment)
  73.  
  74.  
  75. (autoload-from-file (string-append my-path "char.scm") 
  76.                     '(char<? char>? char=? char<=? char>=?
  77.                       char-ci<? char-ci>? char-ci=? char-ci<=?
  78.                       char-ci>=? char-upper-case?
  79.                       char-lower-case? char-digit?)
  80.                     user-global-environment)
  81.  
  82. (autoload-from-file (string-append my-path "sort.scm") 
  83.                     '(sort!)
  84.                     user-global-environment)
  85.  
  86. (autoload-from-file (string-append my-path "debug.scm") 
  87.                     '(break unbreak *tracer* trace untrace assert)
  88.                     user-global-environment)
  89.  
  90. (autoload-from-file (string-append my-path "vector.scm") 
  91.                     '(vector-copy vector-append vector-reverse
  92.                       vector-reverse! vector-map vector-for-each)
  93.                     user-global-environment)
  94.  
  95. (define #\backspace (integer->char 8))
  96.  
  97. (define #\escape (integer->char 27))
  98.  
  99. (define #\newline (integer->char 10))
  100.  
  101. (define #\page (integer->char 12))
  102.  
  103. (define #\return (integer->char 13))
  104.  
  105. (define #\rubout (integer->char 63))
  106.  
  107. (define #\space (integer->char 32))
  108.  
  109. (define #\tab (integer->char 9))
  110.  
  111. (macro make-environment (lambda (x)
  112.                                 `(let () 
  113.                                       ,@(cdr x) 
  114.                                       (the-environment))))
  115.  
  116. (macro alias 
  117.        (lambda (x)
  118.                `(macro ,(cadr x)
  119.                        (lambda (e)
  120.                                (if (pair? e) 
  121.                                    (cons ,(caddr x) (cdr e))
  122.                                    ,(caddr x))))))
  123.  
  124. (macro rec (lambda (x)
  125.                    `(letrec ((,(cadr x) ,(caddr x)))
  126.                             ,(cadr x))))
  127.  
  128. (define (boolean? x) (or (eq? x #t) (eq? x #f)))
  129.  
  130. (define time-of-day runtime)
  131.  
  132. (define nth list-ref)
  133.  
  134. (define (compose x y)
  135.         (eval `(lambda a (,x (apply ,y a)))))
  136.  
  137. (define (edit)
  138.         (begin (dos-call "c:ed siod.tmp")
  139.                (load "siod.tmp" (environment-parent (the-environment)))))
  140.  
  141. (define (ced)
  142.         (dos-call "ced"))
  143.  
  144. (define (call-with-current-continuation fcn)
  145.   (let ((tag (cons nil nil)))
  146.     (*catch tag
  147.        (fcn (lambda (value)
  148.          (*throw tag value))))))
  149.  
  150. (define call/cc call-with-current-continuation)
  151.  
  152. (define (call-on-reset p)
  153.         (if (proc? p)
  154.             (eval `(set! err-stack (cons ,p err-stack))
  155.                   *on-reset-env*)
  156.             (error "arg to call-on-reset must be a procedure"))
  157.         #t)
  158.  
  159. (define *on-reset-env*
  160.         (make-environment (define err-stack)
  161.                           (define p)
  162.                           (define (reset-handler)
  163.                                   (while err-stack
  164.                                          (set! p (car err-stack))
  165.                                          (set! err-stack (cdr err-stack))
  166.                                          (p)))))
  167.  
  168. (set! *on-reset* (access reset-handler *on-reset-env*))
  169.  
  170. (define (uncall-on-reset p)
  171.         (if (proc? p)
  172.         (eval `(set! err-stack (delq! ,p err-stack))
  173.               *on-reset-env*)
  174.             (error "arg to call-on-reset must be a procedure"))
  175.         #t)
  176.  
  177. (macro cycle (lambda (e)
  178.                      `(while #t ,@(cdr e))))
  179.  
  180. (macro repeat 
  181.        (lambda (e)
  182.                `(begin ,(cadr e) (while ,(caddr e) ,(cadr e)))))
  183.  
  184. (macro for
  185.        (lambda (e)
  186.                `(do ((,(cadr e) ,(caddr e) ,(cadddr e)))
  187.                     (,(car (cddddr e)))
  188.                     ,@(cdr (cddddr e)))))
  189.